#include "gather.h"
#include "heart.h"
#include "led01.h"
#include "FreeRTOS.h"
#include "task.h"
#include "dht11.h"
#include "stdio.h"
#include "adc.h"
#include "rain.h"
#include "handler.h"

TaskHandle_t gather_task_handler;

void gather_Init(){
    DHT11_Init();
	  ADCx_Init();
	  rainInit();
}

void gather_task(void * param){
			while(1){
				GatherData source;
				
				DHT11_Read_Data(&source.temp , &source.humi);
			
			  //PB1
	      source.sunshine=Get_ADC_Value(ADC_Channel_9,1);
	    
		    //PB0
	      //source.smoke=Get_ADC_Value(ADC_Channel_8,1);
	    
			
				source.raindrop=DATA_PIN_READ;
				
				dataHandle(&source);
				vTaskDelay(1000);
		}
}

void createGatherTask(){
     xTaskCreate(gather_task,"gather_task",128,NULL,2,&gather_task_handler);
}